//
//  HACChartDefine.h
//  Pods
//
//  Created by Hotacool on 2017/8/30.
//
//

#ifndef HACChartDefine_h
#define HACChartDefine_h
static NSInteger kDrawingInvaildValue = -686868; // 值不存在时，设置的默认无效值

#ifndef dimof
#define dimof(a)    (sizeof(a) / sizeof(a[0]))
#endif

#pragma mark --- Define

/** 当前item在队列中的位置 */
typedef enum : NSUInteger {
    QueueLocationHead,    /** 头部 */
    QueueLocationTrail,   /** 尾部 */
    QueueLocationMiddle,  /** 其它位置 */
} QueueLocation;

/** 当前item的涨跌类型 */
typedef enum : NSUInteger {
    DrawingUpValue, /** 涨 */
    DrawingDownValue, /** 跌 */
    DrawingEqualValue, /** 平 */
} DrawingValueType;

/** 绘制轴的类型 */
typedef enum : NSUInteger {
    DrawingAxisTypeX, /** x轴 */
    DrawingAxisTypeY, /** y轴 */
} DrawingAxisType;


#pragma mark ----- CGLine

/** k线指标类型 */
typedef enum : NSUInteger {
    DrawingIdxTypeMA,
    DrawingIdxTypeVOL,
    DrawingIdxTypeMACD,
    DrawingIdxTypeRSI,
    DrawingIdxTypeWR,
    DrawingIdxTypeKDJ,
    DrawingIdxTypePSY,
    DrawingIdxTypeBIAS,
    DrawingIdxTypeASI,
    DrawingIdxTypeVR,
    DrawingIdxTypeBOLL,
    DrawingIdxTypeOBV,
    DrawingIdxTypeDMA,
    DrawingIdxTypeDMI,
    DrawingIdxTypeDMIDI,
    DrawingIdxTypeVOLHS,
    DrawingIdxTypeCCI,
} DrawingIdxType;


#pragma mark ----- CGLine

struct CGLine
{
    CGPoint start;
    CGPoint end;
};
typedef struct CGLine CGLine; //

static inline CGLine CGLineMake(CGFloat x1, CGFloat y1, CGFloat x2, CGFloat y2)
{
    return (CGLine){.start = CGPointMake(x1, y1), .end = CGPointMake(x2, y2)};
}

static inline QueueLocation CGQueueLocation(NSInteger index, NSInteger totolCount)
{
    if (index == 0)
        return QueueLocationHead;
    else if (index == totolCount - 1)
        return QueueLocationTrail;
    return QueueLocationMiddle;
}

static inline NSTextAlignment CGTextAlignment(NSInteger index, NSInteger totolCount)
{
    if (index == 0)
        return NSTextAlignmentLeft;
    else if (index == totolCount - 1)
        return NSTextAlignmentRight;
    return NSTextAlignmentCenter;
}

// 保留小数点
static inline CGFloat FormatValueWithRemain(CGFloat value ,NSInteger remain)
{
    NSString *base = [NSString stringWithFormat:@"%%.%ldf",(long)remain];
    NSString *formatValue = [NSString stringWithFormat:base, value];
    return [formatValue floatValue];
}

#endif /* HACChartDefine_h */
